﻿Imports System.Data.SqlClient

Public Class clsEvaluacionInternaDetalle
    Private mintidEvaluacionInternaDetalle As Integer
    Private mintIDEmpleado As Integer
    Private mintEvaluacion As Integer
    Private mstrMes As String
    Private mintAnio As Integer
    Private mintRendimiento As Integer
    Private mintCuidado As Integer
    Private mintManejo As Integer
    Private mintUsuario As Integer
    Private mintDisponible As Integer

    Public Property IdEvaluacionInternaDetalle() As Integer
        Get
            Return mintidEvaluacionInternaDetalle
        End Get
        Set(ByVal value As Integer)
            mintidEvaluacionInternaDetalle = value
        End Set
    End Property
    Public Property IdEmpleado() As Integer
        Get
            Return mintIDEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIDEmpleado = value
        End Set
    End Property
    Public Property Evaluacion() As Integer
        Get
            Return mintEvaluacion
        End Get
        Set(ByVal value As Integer)
            mintEvaluacion = value
        End Set
    End Property
    Public Property Mes() As String
        Get
            Return mstrMes
        End Get
        Set(ByVal value As String)
            mstrMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Rendimiento() As Integer
        Get
            Return mintRendimiento
        End Get
        Set(ByVal value As Integer)
            mintRendimiento = value
        End Set
    End Property
    Public Property Cuidado() As Integer
        Get
            Return mintCuidado
        End Get
        Set(ByVal value As Integer)
            mintCuidado = value
        End Set
    End Property
    Public Property Manejo() As Integer
        Get
            Return mintManejo
        End Get
        Set(ByVal value As Integer)
            mintManejo = value
        End Set
    End Property
    Public Property Usuario() As Integer
        Get
            Return mintUsuario
        End Get
        Set(ByVal value As Integer)
            mintUsuario = value
        End Set
    End Property
    Public Property Disponible() As Integer
        Get
            Return mintDisponible
        End Get
        Set(ByVal value As Integer)
            mintDisponible = value
        End Set
    End Property
    Public Sub New()
        mintidEvaluacionInternaDetalle = 0
        mintIDEmpleado = 0
        mintEvaluacion = 0
        mstrMes = ""
        mintAnio = 0
        mintRendimiento = 0
        mintCuidado = 0
        mintManejo = 0
        mintUsuario = 0
        mintDisponible = 0
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From EvaluacionInternaDetalle Where idempleado = " & IdEmpleado & " and mes='" & Mes & "' and anio=" & Anio)

    End Sub
  
    Public Sub Insertar()
        Dim sql As String = "Insert Into EvaluacionInternaDetalle (" & _
                            "IdEvaluacionInternaDetalle," & _
                            "IdEmpleado," & _
                            "Evaluacion," & _
                            "Mes," & _
                            "Anio," & _
                            "Rendimiento," & _
                            "Cuidado," & _
                            "Manejo," & _
                            "Usuario," & _
                            "Disponible) " & _
                            "VALUES (" & _
                            "@IdEvaluacionInternaDetalle," & _
                            "@IdEmpleado," & _
                            "@Evaluacion," & _
                            "substring(@Mes,1,10)," & _
                            "@Anio," & _
                            "@Rendimiento," & _
                            "@Cuidado," & _
                            "@Manejo," & _
                            "@Usuario," & _
                            "@Disponible)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEvaluacionInternaDetalle", mintidEvaluacionInternaDetalle)
        Command.Parameters.AddWithValue("IdEmpleado", mintIDEmpleado)
        Command.Parameters.AddWithValue("Evaluacion", mintEvaluacion)
        Command.Parameters.AddWithValue("Mes", mstrMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Rendimiento", mintRendimiento)
        Command.Parameters.AddWithValue("Cuidado", mintCuidado)
        Command.Parameters.AddWithValue("Manejo", mintManejo)
        Command.Parameters.AddWithValue("Usuario", mintUsuario)
        Command.Parameters.AddWithValue("Disponible", mintDisponible)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la evaluacion", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
